﻿using System;
using System.Data;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
using log4net;
using AjaxPro;
using System.Reflection;
using AnyOffice.general.ipanel;

namespace AnyOffice.general
{
    public partial class login_info : BasePage
    {
        public int state=1;
        public string textState;

        private static ILog log =  LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        public login_info()
        {
            this.state = 1;
            this.textState = string.Empty;
        }        

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.AppendHeader("Expires", DateTime.Now.AddDays(-1.0).ToString("r"));
            Response.AppendHeader("Pragma", "no-cache");
            Response.AppendHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
            Utility.RegisterTypeForAjax(typeof(AjaxMethods));
            ConfigManager manager = new ConfigManager();
            if (manager.RtxEnabled)
            {
                try
                {
                    Type type = Assembly.LoadFrom(Server.MapPath("/bin/RTX.dll")).GetType("RTX.RtxSdk", true);
                    object obj2 = Activator.CreateInstance(type);
                    object obj3 = type.GetMethod("SSO").Invoke(obj2, new object[] { base.User.Identity.Name });
                    if (obj3 != null)
                    {
                        this.Page.RegisterClientScriptBlock("rtx", obj3.ToString());
                    }
                }
                catch (Exception exception)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("RTX", exception);
                    }
                }
            }
            UserCache cache = new UserCache(base.User.Identity.Name);
            this.lblUserName.Text = cache.UserName;
            this.lblDeptName.Text = cache.DeptName;
            this.lblPrivName.Text = cache.PrivName;
            this.imgAvatar.ImageUrl = "/images/avatar/" + cache.Avatar.ToString() + ".gif";
            this.state = cache.State;
            switch (cache.State)
            {
                case 1:
                    this.textState = "联机";
                    break;

                case 2:
                    this.textState = "忙碌";
                    break;

                case 3:
                    this.textState = "离开";
                    break;

                default:
                    this.textState = "联机";
                    break;
            }
          
        }

    }
}
